<?php
	
	require_once(dirname(__FILE__)."/../core/safeParam.php");
	
	class module{
		function Add($vars, $files){
			global $database;
    		$vars['image'] = uploadImage($files, $vars['width'], $vars['height'], '../UserFiles/Image/product_photos/', 'image');
    		$database->insert_array('ads', $vars);
    		
    		if (isset($_GET['return'])) {
    			header("Location: ../admin/index.php?edit=ads&updated=1&lid=" . $_GET['return'] . "");
    		} else {
    			header("Location: ../admin/index.php?edit=ads&updated=1");
    		}
  		}
  		
  		function Edit($vars, $files){
    		global $database;
    		$database->update_array('ads', $vars, "id = " . $vars['id'] . "");
    		
    		if (isset($_GET['return'])) {
      		header("Location: ../admin/index.php?edit=ads&updated=1&lid=" . $_GET['return'] . "");
    		} else {
      		header("Location: ../admin/index.php?edit=ads&updated=1");
    		}
  		}
  		
  		function Delete($vars){
    		global $database;
    		$database->delete('ads', "id = " . $vars['id'] . "");
    		
    		if (isset($_GET['return'])) {
      		header("Location: ../admin/index.php?edit=ads&updated=1&lid=" . $_GET['return'] . "");
    		} else {
      		header("Location: ../admin/index.php?edit=ads&updated=1");
    		}
  		}
	}
?>
